#define DEBUG
#include <cstdio>
#define MAXN 1800
#define MAXLEN 1000
#define MAXK 10000

using namespace std;

typedef int Bignum[MAXLEN+1];

int max(int a, int b) {
  return a>b ? a : b;
}

void add(const Bignum a, const Bignum b, Bignum c) {
  c[1]=0, c[0]=max(a[0], b[0]);
  for (int i=1; i<=c[0]; i++) {
    if (i<=a[0]) {
      c[i]+=a[i];
    }
    if (i<=b[0]) {
      c[i]+=b[i];
    }
    c[i+1]=c[i]/MAXK;
    c[i]%=MAXK;
  }
  c[0] = c[c[0]+1] ? c[0]+1 : c[0];
}

void cpy(const Bignum a, Bignum b) {
  for (int i=0; i<=a[0]; i++) {
    b[i]=a[i];
  }
}

void print(Bignum a) {
  printf("%d", a[a[0]]);
  for (int i=a[0]-1; i>0; i--) {
    printf("%04d", a[i]);
  }
}

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif

  static Bignum f[MAXN+1][10], temp[2];
  int n, k;
  scanf("%d %d", &n, &k);
  f[0][1][0]=1, f[0][1][1]=1;
  for (int i=1; i<=n; i++) {
    temp[0][0]=0;
    for (int j=1; j<k; j++) {
      add(temp[(j-1)%2], f[i-1][j], temp[j%2]);
    }
    cpy(temp[(k-1)%2], f[i][0]);
    add(temp[(k-1)%2], f[i-1][0], temp[k%2]);
    for (int j=1; j<k; j++) {
      cpy(temp[k%2], f[i][j]);
    }
  }

  temp[0][0]=0;
  for (int j=1; j<k; j++) {
    add(temp[(j-1)%2], f[n][j], temp[j%2]);
  }
  print(temp[(k-1)%2]);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
